<?php
namespace app\admin\model;
use think\Model;
class Vegetables extends Model
{
    public function index()
    {   
         
    }
    
    //从蔬菜表和供应商表获取蔬菜信息以及对应的供应商
    public function getvegetables()
    {    
    	 $data = [
            'zhuangtai' =>1,
    	 ];
         return $vegetables = model('Vegetables')
                      ->alias("v")
                      ->join('gongyingshang g','g.gid=v.gid','LEFT')
                      ->field('v.vid,v.paixu,v.url,v.leixing,v.vname,v.kucun,v.price,g.gname,v.status')
                      ->where($data)
                      ->select();
             
    }
     
    //蔬菜商品详情页查询蔬菜商品,以及对应的供应商
    public function shucaichaxun($vname)
    {
    	$data = [
            'zhuangtai' =>1,
            'vname' => $vname,
    	];
        return $shucaichaxun = model('Vegetables')
                            ->alias("v")
                            ->join('gongyingshang g','g.gid=v.gid','LEFT')
                            ->field('v.vid,v.paixu,v.url,v.leixing,v.vname,v.kucun,v.price,g.gname,v.status')
                            ->where($data)
                            ->select();
    }

    //从蔬菜表和供应商表获取指定id的一条蔬菜信息
    public function getvegetable($id)
    {
       $data = [
          'zhuangtai' =>1,
          'vid' =>$id,
       ];
         return $vegetables = model('Vegetables')
                      ->alias("v")
                      ->join('gongyingshang g','g.gid=v.gid','LEFT')
                      ->field('v.vid,v.paixu,v.url,v.leixing,v.vname,v.kucun,v.price,g.gname,v.status')
                      ->where($data)
                      ->find();
    }

}
